home *** CD-ROM | disk | FTP | other *** search
/ Nautilus 1992 July / Nautilus-3-8 / Nautilus-3-8.bin / Tools & Utilities / Techy Stuff / Development Environments ƒ / Perl 4.0.2 ƒ / perl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-05  |  21.0 KB  |  1,008 lines

  1. /* $RCSfile: perl.h,v $$Revision: 4.0.1.5 $$Date: 91/11/11 16:41:07 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  * $Log:    perl.h,v $
  9.  * Revision 4.0.1.5  91/11/11  16:41:07  lwall
  10.  * patch19: uts wrongly defines S_ISDIR() et al
  11.  * patch19: too many preprocessors can't expand a macro right in #if
  12.  * patch19: added little-endian pack/unpack options
  13.  * 
  14.  * Revision 4.0.1.4  91/11/05  18:06:10  lwall
  15.  * patch11: various portability fixes
  16.  * patch11: added support for dbz
  17.  * patch11: added some support for 64-bit integers
  18.  * patch11: hex() didn't understand leading 0x
  19.  * 
  20.  * Revision 4.0.1.3  91/06/10  01:25:10  lwall
  21.  * patch10: certain pattern optimizations were botched
  22.  * 
  23.  * Revision 4.0.1.2  91/06/07  11:28:33  lwall
  24.  * patch4: new copyright notice
  25.  * patch4: made some allowances for "semi-standard" C
  26.  * patch4: many, many itty-bitty portability fixes
  27.  * 
  28.  * Revision 4.0.1.1  91/04/11  17:49:51  lwall
  29.  * patch1: hopefully straightened out some of the Xenix mess
  30.  * 
  31.  * Revision 4.0  91/03/20  01:37:56  lwall
  32.  * 4.0 baseline.
  33.  * 
  34.  */
  35.  
  36. #define VOIDWANT 1
  37. #include "config.h"
  38.  
  39. /* [Macintosh] The Mac is almost MS-DOS compatible:
  40.    no userids, no groupids, no forking
  41. */
  42.  
  43. #ifdef MSDOS
  44. #define MSMAC
  45. #else
  46. #ifdef macintosh
  47. #define MSMAC
  48. #else
  49. #undef MSMAC
  50. #endif
  51. #endif
  52.  
  53. #ifdef MYMALLOC
  54. #   ifdef HIDEMYMALLOC
  55. #    define malloc Mymalloc
  56. #    define realloc Myremalloc
  57. #    define free Myfree
  58. #   endif
  59. #   define safemalloc malloc
  60. #   define saferealloc realloc
  61. #   define safefree free
  62. #endif
  63.  
  64. /* work around some libPW problems */
  65. #define fatal Myfatal
  66. #ifdef DOINIT
  67. char Error[1];
  68. #endif
  69.  
  70. #ifdef MSMAC
  71. /* This stuff now in the MS-DOS config.h file. */
  72. #else /* !MSMAC */
  73.  
  74. /*
  75.  * The following symbols are defined if your operating system supports
  76.  * functions by that name.  All Unixes I know of support them, thus they
  77.  * are not checked by the configuration script, but are directly defined
  78.  * here.
  79.  */
  80. #define HAS_ALARM
  81. #define HAS_CHOWN
  82. #define HAS_CHROOT
  83. #define HAS_FORK
  84. #define HAS_GETLOGIN
  85. #define HAS_GETPPID
  86. #define HAS_KILL
  87. #define HAS_LINK
  88. #define HAS_PIPE
  89. #define HAS_WAIT
  90. #define HAS_UMASK
  91. /*
  92.  * The following symbols are defined if your operating system supports
  93.  * password and group functions in general.  All Unix systems do.
  94.  */
  95. #define HAS_GROUP
  96. #define HAS_PASSWD
  97.  
  98. #endif /* !MSMAC */
  99.  
  100. #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
  101. # define STANDARD_C 1
  102. #endif
  103.  
  104. /* [Macintosh] MPW C 3.1 seems to be not quite ANSI-compatible */
  105.  
  106. #ifdef STANDARD_C
  107. #define    STDMAC
  108. #else
  109. #ifdef macintosh
  110. #define    STDMAC
  111. #else
  112. #undef STDMAC
  113. #endif
  114. #endif
  115.  
  116. #if defined(HASVOLATILE) || defined(STANDARD_C)
  117. #define VOLATILE volatile
  118. #else
  119. #define VOLATILE
  120. #endif
  121.  
  122. #ifdef IAMSUID
  123. #   ifndef TAINT
  124. #    define TAINT
  125. #   endif
  126. #endif
  127.  
  128. #ifndef HAS_VFORK
  129. #   define vfork fork
  130. #endif
  131.  
  132. #ifdef HAS_GETPGRP2
  133. #   ifndef HAS_GETPGRP
  134. #    define HAS_GETPGRP
  135. #   endif
  136. #   define getpgrp getpgrp2
  137. #endif
  138.  
  139. #ifdef HAS_SETPGRP2
  140. #   ifndef HAS_SETPGRP
  141. #    define HAS_SETPGRP
  142. #   endif
  143. #   define setpgrp setpgrp2
  144. #endif
  145.  
  146. #include <stdio.h>
  147. #include <ctype.h>
  148. #include <setjmp.h>
  149. #ifndef MSMAC
  150. #ifdef PARAM_NEEDS_TYPES
  151. #include <sys/types.h>
  152. #endif
  153. #include <sys/param.h>
  154. #endif
  155. #ifdef STDMAC
  156. /* Use all the "standard" definitions */
  157. #include <stdlib.h>
  158. #include <string.h>
  159. #endif /* STDMAC */
  160.  
  161. #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
  162. #undef HAS_MEMCMP
  163. #endif
  164.  
  165. #ifdef HAS_MEMCPY
  166.  
  167. #  ifndef STDMAC
  168. #    ifndef memcpy
  169. extern char * memcpy(), *memset();
  170. extern int memcmp();
  171. #    endif /* ndef memcpy */
  172. #  endif /* ndef STDMAC */
  173.  
  174. #   ifndef bcopy
  175. #    define bcopy(s1,s2,l) memcpy(s2,s1,l)
  176. #   endif
  177. #   ifndef bzero
  178. #    define bzero(s,l) memset(s,0,l)
  179. #   endif
  180. #endif /* HAS_MEMCPY */
  181.  
  182. #ifndef HAS_BCMP        /* prefer bcmp slightly 'cuz it doesn't order */
  183. #   ifndef bcmp
  184. #    define bcmp(s1,s2,l) memcmp(s1,s2,l)
  185. #   endif
  186. #endif
  187.  
  188. #ifndef macintosh
  189. #ifndef _TYPES_        /* If types.h defines this it's easy. */
  190. #ifndef major        /* Does everyone's types.h define this? */
  191. #include <sys/types.h>
  192. #endif
  193. #endif
  194. #endif
  195.  
  196. #ifdef I_NETINET_IN
  197. #include <netinet/in.h>
  198. #endif
  199.  
  200. #ifndef macintosh
  201. #include <sys/stat.h>
  202. #ifdef uts
  203. #undef S_ISDIR
  204. #undef S_ISCHR
  205. #undef S_ISBLK
  206. #undef S_ISREG
  207. #undef S_ISFIFO
  208. #undef S_ISLNK
  209. #define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
  210. #define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
  211. #define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
  212. #define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
  213. #define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
  214. #define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
  215. #endif
  216. #endif
  217.  
  218. #ifdef I_TIME
  219. #        include <time.h>
  220. #endif
  221.  
  222. #ifdef I_SYS_TIME
  223. #   ifdef SYSTIMEKERNEL
  224. #    define KERNEL
  225. #   endif
  226. #   include <sys/time.h>
  227. #   ifdef SYSTIMEKERNEL
  228. #    undef KERNEL
  229. #   endif
  230. #endif
  231.  
  232. #ifndef MSMAC
  233. #include <sys/times.h>
  234. #endif
  235.  
  236. #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
  237. #undef HAS_STRERROR
  238. #endif
  239.  
  240. #include <errno.h>
  241. #ifndef MSDOS
  242. #ifndef errno
  243. extern int errno;     /* ANSI allows errno to be an lvalue expr */
  244. #endif
  245. #endif
  246.  
  247. #ifndef strerror
  248. #ifdef HAS_STRERROR
  249. char *strerror();
  250. #else
  251. extern int sys_nerr;
  252. extern char *sys_errlist[];
  253. #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
  254. #endif
  255. #endif
  256.  
  257. #ifdef I_SYSIOCTL
  258. #ifndef _IOCTL_
  259. #include <sys/ioctl.h>
  260. #endif
  261. #endif
  262.  
  263. #if defined(mc300) || defined(mc500) || defined(mc700)    /* MASSCOMP */
  264. #ifdef HAS_SOCKETPAIR
  265. #undef HAS_SOCKETPAIR
  266. #endif
  267. #ifdef HAS_NDBM
  268. #undef HAS_NDBM
  269. #endif
  270. #endif
  271.  
  272. #ifdef WANT_DBZ
  273. #include <dbz.h>
  274. #define SOME_DBM
  275. #define dbm_fetch(db,dkey) fetch(dkey)
  276. #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
  277. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  278. #define dbm_close(db) dbmclose()
  279. #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  280. #define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
  281. #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  282. #ifdef HAS_NDBM
  283. #undef HAS_NDBM
  284. #endif
  285. #ifndef HAS_ODBM
  286. #define HAS_ODBM
  287. #endif
  288. #else
  289. #ifdef HAS_GDBM
  290. #ifdef I_GDBM
  291. #include <gdbm.h>
  292. #endif
  293. #define SOME_DBM
  294. #ifdef HAS_NDBM
  295. #undef HAS_NDBM
  296. #endif
  297. #ifdef HAS_ODBM
  298. #undef HAS_ODBM
  299. #endif
  300. #else
  301. #ifdef HAS_NDBM
  302. #include <ndbm.h>
  303. #define SOME_DBM
  304. #ifdef HAS_ODBM
  305. #undef HAS_ODBM
  306. #endif
  307. #else
  308. #ifdef HAS_ODBM
  309. #ifdef NULL
  310. #undef NULL        /* suppress redefinition message */
  311. #endif
  312. #include <dbm.h>
  313. #ifdef NULL
  314. #undef NULL
  315. #endif
  316. #define NULL 0        /* silly thing is, we don't even use this */
  317. #define SOME_DBM
  318. #define dbm_fetch(db,dkey) fetch(dkey)
  319. #define dbm_delete(db,dkey) delete(dkey)
  320. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  321. #define dbm_close(db) dbmclose()
  322. #define dbm_firstkey(db) firstkey()
  323. #endif /* HAS_ODBM */
  324. #endif /* HAS_NDBM */
  325. #endif /* HAS_GDBM */
  326. #endif /* WANT_DBZ */
  327. #ifdef SOME_DBM
  328. EXT char *dbmkey;
  329. EXT int dbmlen;
  330. #endif
  331.  
  332. #if INTSIZE == 2
  333. #define htoni htons
  334. #define ntohi ntohs
  335. #else
  336. #define htoni htonl
  337. #define ntohi ntohl
  338. #endif
  339.  
  340. #if defined(I_DIRENT)
  341. #   include <dirent.h>
  342. #   define DIRENT dirent
  343. #else
  344. #   ifdef I_SYS_NDIR
  345. #    include <sys/ndir.h>
  346. #    define DIRENT direct
  347. #   else
  348. #    ifdef I_SYS_DIR
  349. #        ifdef hp9000s500
  350. #        include <ndir.h>    /* may be wrong in the future */
  351. #        else
  352. #        include <sys/dir.h>
  353. #        endif
  354. #        define DIRENT direct
  355. #    endif
  356. #   endif
  357. #endif
  358.  
  359. #ifdef macintosh
  360. #include "UnixFiles.h"
  361. #include "SubLaunch.h"
  362. #include <CursorCtl.h>
  363.  
  364. void InitToolbox();
  365. init_macintosh();
  366. void GetProgFile(FSSpec *);
  367. void SpinPerlCursor(int);
  368. #endif
  369.  
  370. #ifdef FPUTS_BOTCH
  371. /* work around botch in SunOS 4.0.1 and 4.0.2 */
  372. #   ifndef fputs
  373. #    define fputs(str,fp) fprintf(fp,"%s",str)
  374. #   endif
  375. #endif
  376.  
  377. /*
  378.  * The following gobbledygook brought to you on behalf of __STDC__.
  379.  * (I could just use #ifndef __STDC__, but this is more bulletproof
  380.  * in the face of half-implementations.)
  381.  */
  382.  
  383. #ifndef S_IFMT
  384. #   ifdef _S_IFMT
  385. #    define S_IFMT _S_IFMT
  386. #   else
  387. #    define S_IFMT 0170000
  388. #   endif
  389. #endif
  390.  
  391. #ifndef S_ISDIR
  392. #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
  393. #endif
  394.  
  395. #ifndef S_ISCHR
  396. #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
  397. #endif
  398.  
  399. #ifndef S_ISBLK
  400. #   ifdef S_IFBLK
  401. #    define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
  402. #   else
  403. #    define S_ISBLK(m) (0)
  404. #   endif
  405. #endif
  406.  
  407. #ifndef S_ISREG
  408. #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  409. #endif
  410.  
  411. #ifndef S_ISFIFO
  412. #   ifdef S_IFIFO
  413. #    define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
  414. #   else
  415. #    define S_ISFIFO(m) (0)
  416. #   endif
  417. #endif
  418.  
  419. #ifndef S_ISLNK
  420. #   ifdef _S_ISLNK
  421. #    define S_ISLNK(m) _S_ISLNK(m)
  422. #   else
  423. #    ifdef _S_IFLNK
  424. #        define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
  425. #    else
  426. #        ifdef S_IFLNK
  427. #        define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  428. #        else
  429. #        define S_ISLNK(m) (0)
  430. #        endif
  431. #    endif
  432. #   endif
  433. #endif
  434.  
  435. #ifndef S_ISSOCK
  436. #   ifdef _S_ISSOCK
  437. #    define S_ISSOCK(m) _S_ISSOCK(m)
  438. #   else
  439. #    ifdef _S_IFSOCK
  440. #        define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
  441. #    else
  442. #        ifdef S_IFSOCK
  443. #        define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
  444. #        else
  445. #        define S_ISSOCK(m) (0)
  446. #        endif
  447. #    endif
  448. #   endif
  449. #endif
  450.  
  451. #ifndef S_IRUSR
  452. #   ifdef S_IREAD
  453. #    define S_IRUSR S_IREAD
  454. #    define S_IWUSR S_IWRITE
  455. #    define S_IXUSR S_IEXEC
  456. #   else
  457. #    define S_IRUSR 0400
  458. #    define S_IWUSR 0200
  459. #    define S_IXUSR 0100
  460. #   endif
  461. #   define S_IRGRP (S_IRUSR>>3)
  462. #   define S_IWGRP (S_IWUSR>>3)
  463. #   define S_IXGRP (S_IXUSR>>3)
  464. #   define S_IROTH (S_IRUSR>>6)
  465. #   define S_IWOTH (S_IWUSR>>6)
  466. #   define S_IXOTH (S_IXUSR>>6)
  467. #endif
  468.  
  469. #ifndef S_ISUID
  470. #   define S_ISUID 04000
  471. #endif
  472.  
  473. #ifndef S_ISGID
  474. #   define S_ISGID 02000
  475. #endif
  476.  
  477. #ifdef f_next
  478. #undef f_next
  479. #endif
  480.  
  481. #if defined(cray) || defined(gould)
  482. #   define SLOPPYDIVIDE
  483. #endif
  484.  
  485. #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
  486. #   define QUAD
  487. #endif
  488.  
  489. #ifdef QUAD
  490. #   ifdef cray
  491. #    define quad int
  492. #   else
  493. #    if defined(convex) || defined (uts)
  494. #        define quad long long
  495. #    else
  496. #        define quad long
  497. #    endif
  498. #   endif
  499. #endif
  500.  
  501. typedef unsigned int STRLEN;
  502.  
  503. typedef struct arg ARG;
  504. typedef struct cmd CMD;
  505. typedef struct formcmd FCMD;
  506. typedef struct scanpat SPAT;
  507. typedef struct stio STIO;
  508. typedef struct sub SUBR;
  509. typedef struct string STR;
  510. typedef struct atbl ARRAY;
  511. typedef struct htbl HASH;
  512. typedef struct regexp REGEXP;
  513. typedef struct stabptrs STBP;
  514. typedef struct stab STAB;
  515. typedef struct callsave CSV;
  516.  
  517. #include "handy.h"
  518. #include "regexp.h"
  519. #include "str.h"
  520. #include "util.h"
  521. #include "form.h"
  522. #include "stab.h"
  523. #include "spat.h"
  524. #include "arg.h"
  525. #include "cmd.h"
  526. #include "array.h"
  527. #include "hash.h"
  528.  
  529. #if defined(iAPX286) || defined(M_I286) || defined(I80286)
  530. #   define I286
  531. #endif
  532.  
  533. #ifndef    STDMAC
  534. #ifdef CHARSPRINTF
  535.     char *sprintf();
  536. #else
  537.     int sprintf();
  538. #endif
  539. #endif
  540.  
  541. EXT char *Yes INIT("1");
  542. EXT char *No INIT("");
  543.  
  544. /* "gimme" values */
  545.  
  546. /* Note: cmd.c assumes that it can use && to produce one of these values! */
  547. #define G_SCALAR 0
  548. #define G_ARRAY 1
  549.  
  550. #ifdef CRIPPLED_CC
  551. int str_true();
  552. #else /* !CRIPPLED_CC */
  553. #define str_true(str) (Str = (str), \
  554.     (Str->str_pok ? \
  555.         ((*Str->str_ptr > '0' || \
  556.           Str->str_cur > 1 || \
  557.           (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
  558.     : \
  559.         (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
  560. #endif /* CRIPPLED_CC */
  561.  
  562. #ifdef DEBUGGING
  563. #define str_peek(str) (Str = (str), \
  564.     (Str->str_pok ? \
  565.         Str->str_ptr : \
  566.         (Str->str_nok ? \
  567.         (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
  568.             (char*)tokenbuf) : \
  569.         "" )))
  570. #endif
  571.  
  572. #ifdef CRIPPLED_CC
  573. char *str_get();
  574. #else
  575. #ifdef TAINT
  576. #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
  577.     (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  578. #else
  579. #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  580. #endif /* TAINT */
  581. #endif /* CRIPPLED_CC */
  582.  
  583. #ifdef CRIPPLED_CC
  584. double str_gnum();
  585. #else /* !CRIPPLED_CC */
  586. #ifdef TAINT
  587. #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
  588.     (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  589. #else /* !TAINT */
  590. #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  591. #endif /* TAINT*/
  592. #endif /* CRIPPLED_CC */
  593. EXT STR *Str;
  594.  
  595. #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
  596.  
  597. #ifndef MSDOS
  598. #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
  599. #define Str_Grow str_grow
  600. #else
  601. /* extra parentheses intentionally NOT placed around "len"! */
  602. #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
  603.         str_grow(str,(unsigned long)len)
  604. #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
  605. #endif /* MSDOS */
  606.  
  607. #ifndef BYTEORDER
  608. #define BYTEORDER 0x1234
  609. #endif
  610.  
  611. #if defined(htonl) && !defined(HAS_HTONL)
  612. #define HAS_HTONL
  613. #endif
  614. #if defined(htons) && !defined(HAS_HTONS)
  615. #define HAS_HTONS
  616. #endif
  617. #if defined(ntohl) && !defined(HAS_NTOHL)
  618. #define HAS_NTOHL
  619. #endif
  620. #if defined(ntohs) && !defined(HAS_NTOHS)
  621. #define HAS_NTOHS
  622. #endif
  623. #ifndef HAS_HTONL
  624. #if (BYTEORDER & 0xffff) != 0x4321
  625. #define HAS_HTONS
  626. #define HAS_HTONL
  627. #define HAS_NTOHS
  628. #define HAS_NTOHL
  629. #define MYSWAP
  630. #define htons my_swap
  631. #define htonl my_htonl
  632. #define ntohs my_swap
  633. #define ntohl my_ntohl
  634. #endif
  635. #else
  636. #if (BYTEORDER & 0xffff) == 0x4321
  637. #undef HAS_HTONS
  638. #undef HAS_HTONL
  639. #undef HAS_NTOHS
  640. #undef HAS_NTOHL
  641. #endif
  642. #endif
  643.  
  644. /*
  645.  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
  646.  * -DWS
  647.  */
  648. #if BYTEORDER != 0x1234
  649. # define HAS_VTOHL
  650. # define HAS_VTOHS
  651. # define HAS_HTOVL
  652. # define HAS_HTOVS
  653. # if BYTEORDER == 0x4321
  654. #  define vtohl(x)    ((((x)&0xFF)<<24)    \
  655.             +(((x)>>24)&0xFF)    \
  656.             +(((x)&0x0000FF00)<<8)    \
  657.             +(((x)&0x00FF0000)>>8)    )
  658. #  define vtohs(x)    ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
  659. #  define htovl(x)    vtohl(x)
  660. #  define htovs(x)    vtohs(x)
  661. # endif
  662.     /* otherwise default to functions in util.c */
  663. #endif
  664.  
  665. #ifdef CASTNEGFLOAT
  666. #define U_S(what) ((unsigned short)(what))
  667. #define U_I(what) ((unsigned int)(what))
  668. #define U_L(what) ((unsigned long)(what))
  669. #else
  670. unsigned long castulong();
  671. #define U_S(what) ((unsigned int)castulong(what))
  672. #define U_I(what) ((unsigned int)castulong(what))
  673. #define U_L(what) (castulong(what))
  674. #endif
  675.  
  676. CMD *add_label();
  677. CMD *block_head();
  678. CMD *append_line();
  679. CMD *make_acmd();
  680. CMD *make_ccmd();
  681. CMD *make_icmd();
  682. #ifndef RESOLVE_MAC_CONFLICTS
  683. CMD *invert();
  684. #endif
  685. CMD *addcond();
  686. CMD *addloop();
  687. CMD *wopt();
  688. CMD *over();
  689.  
  690. STAB *stabent();
  691. STAB *genstab();
  692.  
  693. ARG *stab2arg();
  694. ARG *op_new();
  695. ARG *make_op();
  696. ARG *make_match();
  697. ARG *make_split();
  698. ARG *rcatmaybe();
  699. ARG *listish();
  700. ARG *maybelistish();
  701. ARG *localize();
  702. ARG *fixeval();
  703. ARG *jmaybe();
  704. ARG *l();
  705. ARG *fixl();
  706. ARG *mod_match();
  707. ARG *make_list();
  708. ARG *cmd_to_arg();
  709. ARG *addflags();
  710. ARG *hide_ary();
  711. ARG *cval_to_arg();
  712.  
  713. STR *str_new();
  714. STR *stab_str();
  715.  
  716. int do_each();
  717. int do_subr();
  718. int do_match();
  719. int do_unpack();
  720. int eval();        /* this evaluates expressions */
  721. int do_eval();        /* this evaluates eval operator */
  722. int do_assign();
  723.  
  724. SUBR *make_sub();
  725.  
  726. FCMD *load_format();
  727.  
  728. char *scanpat();
  729. char *scansubst();
  730. char *scantrans();
  731. char *scanstr();
  732. char *scanident();
  733. char *str_append_till();
  734. char *str_gets();
  735. char *str_grow();
  736.  
  737. bool do_open();
  738. bool do_close();
  739. bool do_print();
  740. bool do_aprint();
  741. bool do_exec();
  742. bool do_aexec();
  743.  
  744. int do_subst();
  745. int cando();
  746. int ingroup();
  747.  
  748. void str_replace();
  749. void str_inc();
  750. void str_dec();
  751. void str_free();
  752. void stab_clear();
  753. void do_join();
  754. void do_sprintf();
  755. void do_accept();
  756. void do_pipe();
  757. void do_vecset();
  758. void do_unshift();
  759. void do_execfree();
  760. void magicalize();
  761. void magicname();
  762. void savelist();
  763. void saveitem();
  764. void saveint();
  765. void savelong();
  766. void savesptr();
  767. void savehptr();
  768. void restorelist();
  769. void repeatcpy();
  770. HASH *savehash();
  771. ARRAY *saveary();
  772.  
  773. EXT char **origargv;
  774. EXT int origargc;
  775. EXT char **origenviron;
  776. extern char **environ;
  777.  
  778. EXT long subline INIT(0);
  779. EXT STR *subname INIT(Nullstr);
  780. EXT int arybase INIT(0);
  781.  
  782. struct outrec {
  783.     long    o_lines;
  784.     char    *o_str;
  785.     int        o_len;
  786. };
  787.  
  788. EXT struct outrec outrec;
  789. EXT struct outrec toprec;
  790.  
  791. EXT STAB *stdinstab INIT(Nullstab);
  792. EXT STAB *last_in_stab INIT(Nullstab);
  793. EXT STAB *defstab INIT(Nullstab);
  794. EXT STAB *argvstab INIT(Nullstab);
  795. EXT STAB *envstab INIT(Nullstab);
  796. EXT STAB *sigstab INIT(Nullstab);
  797. EXT STAB *defoutstab INIT(Nullstab);
  798. EXT STAB *curoutstab INIT(Nullstab);
  799. EXT STAB *argvoutstab INIT(Nullstab);
  800. EXT STAB *incstab INIT(Nullstab);
  801. EXT STAB *leftstab INIT(Nullstab);
  802. EXT STAB *amperstab INIT(Nullstab);
  803. EXT STAB *rightstab INIT(Nullstab);
  804. EXT STAB *DBstab INIT(Nullstab);
  805. EXT STAB *DBline INIT(Nullstab);
  806. EXT STAB *DBsub INIT(Nullstab);
  807.  
  808. EXT HASH *defstash;        /* main symbol table */
  809. EXT HASH *curstash;        /* symbol table for current package */
  810. EXT HASH *debstash;        /* symbol table for perldb package */
  811.  
  812. EXT STR *curstname;        /* name of current package */
  813.  
  814. EXT STR *freestrroot INIT(Nullstr);
  815. EXT STR *lastretstr INIT(Nullstr);
  816. EXT STR *DBsingle INIT(Nullstr);
  817. EXT STR *DBtrace INIT(Nullstr);
  818. EXT STR *DBsignal INIT(Nullstr);
  819.  
  820. EXT int lastspbase;
  821. EXT int lastsize;
  822.  
  823. EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  824. EXT char *origfilename;
  825. EXT FILE * VOLATILE rsfp;
  826. EXT char buf[1024];
  827. EXT char *bufptr;
  828. EXT char *oldbufptr;
  829. EXT char *oldoldbufptr;
  830. EXT char *bufend;
  831.  
  832. EXT STR *linestr INIT(Nullstr);
  833.  
  834. EXT char *rs INIT("\n");
  835. EXT int rschar INIT('\n');    /* final char of rs, or 0777 if none */
  836. EXT int rslen INIT(1);
  837. EXT char *ofs INIT(Nullch);
  838. EXT int ofslen INIT(0);
  839. EXT char *ors INIT(Nullch);
  840. EXT int orslen INIT(0);
  841. EXT char *ofmt INIT(Nullch);
  842. EXT char *inplace INIT(Nullch);
  843. EXT char *nointrp INIT("");
  844.  
  845. EXT bool preprocess INIT(FALSE);
  846. EXT bool minus_n INIT(FALSE);
  847. EXT bool minus_p INIT(FALSE);
  848. EXT bool minus_l INIT(FALSE);
  849. EXT bool minus_a INIT(FALSE);
  850. EXT bool doswitches INIT(FALSE);
  851. EXT bool dowarn INIT(FALSE);
  852. EXT bool doextract INIT(FALSE);
  853. EXT bool allstabs INIT(FALSE);    /* init all customary symbols in symbol table?*/
  854. EXT bool sawampersand INIT(FALSE);    /* must save all match strings */
  855. EXT bool sawstudy INIT(FALSE);        /* do fbminstr on all strings */
  856. EXT bool sawi INIT(FALSE);        /* study must assume case insensitive */
  857. EXT bool sawvec INIT(FALSE);
  858. EXT bool localizing INIT(FALSE);    /* are we processing a local() list? */
  859.  
  860. #ifndef MAXSYSFD
  861. #   define MAXSYSFD 2
  862. #endif
  863. EXT int maxsysfd INIT(MAXSYSFD);    /* top fd to pass to subprocesses */
  864.  
  865. #ifdef CSH
  866. char *cshname INIT(CSH);
  867. int cshlen INIT(0);
  868. #endif /* CSH */
  869.  
  870. #ifdef TAINT
  871. EXT bool tainted INIT(FALSE);        /* using variables controlled by $< */
  872. #endif
  873.  
  874. #ifndef MSMAC
  875. #define TMPPATH "/tmp/perl-eXXXXXX"
  876. #else
  877. #define TMPPATH "plXXXXXX"
  878. #endif /* MSMAC */
  879. EXT char *e_tmpname;
  880. EXT FILE *e_fp INIT(Nullfp);
  881.  
  882. EXT char tokenbuf[256];
  883. EXT int expectterm INIT(TRUE);        /* how to interpret ambiguous tokens */
  884. EXT VOLATILE int in_eval INIT(FALSE);    /* trap fatal errors? */
  885. EXT int multiline INIT(0);        /* $*--do strings hold >1 line? */
  886. EXT int forkprocess;            /* so do_open |- can return proc# */
  887. EXT int do_undump INIT(0);        /* -u or dump seen? */
  888. EXT int error_count INIT(0);        /* how many errors so far, max 10 */
  889. EXT int multi_start INIT(0);        /* 1st line of multi-line string */
  890. EXT int multi_end INIT(0);        /* last line of multi-line string */
  891. EXT int multi_open INIT(0);        /* delimiter of said string */
  892. EXT int multi_close INIT(0);        /* delimiter of said string */
  893.  
  894. FILE *popen();
  895. /* char *str_get(); */
  896. STR *interp();
  897. void free_arg();
  898. STIO *stio_new();
  899. void hoistmust();
  900. void scanconst();
  901.  
  902. EXT struct stat statbuf;
  903. EXT struct stat statcache;
  904. STAB *statstab INIT(Nullstab);
  905. STR *statname;
  906. #ifndef MSMAC
  907. EXT struct tms timesbuf;
  908. #endif
  909. EXT int uid;
  910. EXT int euid;
  911. EXT int gid;
  912. EXT int egid;
  913. UIDTYPE getuid();
  914. UIDTYPE geteuid();
  915. GIDTYPE getgid();
  916. GIDTYPE getegid();
  917. EXT int unsafe;
  918.  
  919. #ifdef DEBUGGING
  920. EXT VOLATILE int debug INIT(0);
  921. EXT int dlevel INIT(0);
  922. EXT int dlmax INIT(128);
  923. EXT char *debname;
  924. EXT char *debdelim;
  925. #define YYDEBUG 1
  926. #endif
  927. EXT int perldb INIT(0);
  928. #define YYMAXDEPTH 300
  929.  
  930. EXT line_t cmdline INIT(NOLINE);
  931.  
  932. EXT STR str_undef;
  933. EXT STR str_no;
  934. EXT STR str_yes;
  935.  
  936. /* runtime control stuff */
  937.  
  938. EXT struct loop {
  939.     char *loop_label;        /* what the loop was called, if anything */
  940.     int loop_sp;        /* stack pointer to copy stuff down to */
  941.     jmp_buf loop_env;
  942. } *loop_stack;
  943.  
  944. EXT int loop_ptr INIT(-1);
  945. EXT int loop_max INIT(128);
  946.  
  947. EXT jmp_buf top_env;
  948.  
  949. EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
  950.  
  951. struct ufuncs {
  952.     int (*uf_val)();
  953.     int (*uf_set)();
  954.     int uf_index;
  955. };
  956.  
  957. EXT ARRAY *stack;        /* THE STACK */
  958.  
  959. EXT ARRAY * VOLATILE savestack;        /* to save non-local values on */
  960.  
  961. EXT ARRAY *tosave;        /* strings to save on recursive subroutine */
  962.  
  963. EXT ARRAY *lineary;        /* lines of script for debugger */
  964. EXT ARRAY *dbargs;        /* args to call listed by caller function */
  965.  
  966. EXT ARRAY *fdpid;        /* keep fd-to-pid mappings for mypopen */
  967. EXT HASH *pidstatus;        /* keep pid-to-status mappings for waitpid */
  968.  
  969. EXT int *di;            /* for tmp use in debuggers */
  970. EXT char *dc;
  971. EXT short *ds;
  972.  
  973. /* Fix these up for STDMAC */
  974. #ifdef macintosh
  975. EXT time_t basetime INIT(0);
  976. #else
  977. EXT long basetime INIT(0);
  978. #endif
  979. char *mktemp();
  980. #ifndef STDMAC
  981. /* All of these are in stdlib.h or time.h for ANSI C */
  982. double atof();
  983. long time();
  984. struct tm *gmtime(), *localtime();
  985. char *index(), *rindex();
  986. char *strcpy(), *strcat();
  987. #endif /* ! STDMAC */
  988.  
  989. #ifdef EUNICE
  990. #define UNLINK unlnk
  991. int unlnk();
  992. #else
  993. #define UNLINK unlink
  994. #endif
  995.  
  996. #ifndef HAS_SETREUID
  997. #ifdef HAS_SETRESUID
  998. #define setreuid(r,e) setresuid(r,e,-1)
  999. #define HAS_SETREUID
  1000. #endif
  1001. #endif
  1002. #ifndef HAS_SETREGID
  1003. #ifdef HAS_SETRESGID
  1004. #define setregid(r,e) setresgid(r,e,-1)
  1005. #define HAS_SETREGID
  1006. #endif
  1007. #endif
  1008.